<?php
/**
 * Transaction Central Payment
 *
 *
 */
define("TC_CCSALE_URL", 'https://webservices.primerchants.com/billing/TransactionCentral/processCC.asp');
define("TC_CCCREDIT_URL", 'https://webservices.primerchants.com/billing/TransactionCentral/voidcreditcconline.asp');

define("TC_TEST_MERCHANTID", 10011);
define("TC_TEST_REGKEY", 'KK48NPYEJHMAH6DK');
	
class TransactionCentral 
{
	function process($params = array(),$post_url)
	{
		
		$ch = curl_init();
		
        curl_setopt($ch, CURLOPT_URL, $post_url);
		curl_setopt($ch, CURLOPT_POST, 1);
		curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
        curl_setopt($ch, CURLOPT_TIMEOUT, 360);
		curl_setopt($ch, CURLOPT_SSLVERSION, 3);
		
		if (isset($params)) {
            // If fields is an array then turn it into a string. Somtimes
            // cURL doesn't like fields as an array.
            if (is_array($params)) {
                $sets = array();
                foreach ($params as $key => $val) {
                    $sets[] = $key . '=' . urlencode($val);
                }
                $fields = implode('&',$sets);
            } else {
                $fields = $params;
            }
            curl_setopt($ch, CURLOPT_POSTFIELDS, $fields);
        }
		
		$ch_ret = curl_exec($ch);
		
		if (curl_errno($ch)) {
        	//print curl_error($ch);
			return curl_error($ch);
        } else {
        	curl_close($ch);
        }
		
		return $ch_ret;
		
	}
	

}

?>